import React, {Component} from 'react';
import Video from 'react-native-video';
import {StyleSheet} from 'react-native';
import store from '~/store';
import {saveSystem} from '~/store/system';

export default class video extends Component {
    static navigationOptions = {
        headerTransparent: true,
        headerShown: false,
    };

    constructor(props) {
        super(props);
        const getters = store.getState();
        if (getters.system.showSplash) {
            store.dispatch(saveSystem({showSplash: false}));
        } else {
            this.toHome();
        }
    }

    toHome = () => {
        if (global.AppData.versionName === 'dev') {
            this.props.navigation.navigate('SelectRole');
        } else {
            this.props.navigation.navigate('NavigatorTab');
        }
    };

    render() {
        return <Video style={StyleSheet.absoluteFill} resizeMode="cover" onEnd={this.toHome} source={require('~/assets/public/splash.mp4')} />;
    }
}
